'use server';
import {BACKEND_BATH_URL} from "@/lib/constants";
import {db} from "@/lib/db";

export async function getUsers() {
    try {
        // const response =
        //     // await fetch('https://randomuser.me/api/?results=30&inc=name,login,picture');
        //     await fetch(`${BACKEND_BATH_URL}/users`);
        //
        // if (!response.ok) {
        //     throw new Error('Network response was not ok');
        // }
        // const json = await response.json()
        // return json.results

        // 获取数据库前30个用户数据
        const users = await db.user.findMany({
            take: 30,
        })
        return users
    } catch (error) {
        console.error('Failed to fetch news:', error);
        return [];
    }
}
